package com.huawei.zyb.taskManager.domain.project.valueobject;

import java.util.Objects;

/**
 * 项目描述值对象
 */
public final class ProjectDescription {
    private static final int MAX_LENGTH = 2000;
    private final String value;

    private ProjectDescription(String value) {
        this.value = value == null ? "" : value.trim();
        
        if (this.value.length() > MAX_LENGTH) {
            throw new IllegalArgumentException("项目描述长度不能超过" + MAX_LENGTH + "字符");
        }
    }

    public static ProjectDescription of(String value) {
        return new ProjectDescription(value);
    }

    public static ProjectDescription empty() {
        return new ProjectDescription("");
    }

    public String getValue() {
        return value;
    }

    public boolean isEmpty() {
        return value.isEmpty();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        ProjectDescription that = (ProjectDescription) obj;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }

    @Override
    public String toString() {
        return "ProjectDescription{" + value + "}";
    }
}